package main

import (
	"fmt"
	"time"
)

func main() {
	//now := time.Now()
	//t := time.Date(2017, 11, 1, 0, 0, 0, 0, now.Location())
	//t2 := time.Date(t.Year(), t.Month()-1, t.Day(), 0, 0, 0, 0, t.Location())
	//fmt.Println(t)
	//fmt.Println(t.AddDate(0, -1, 0))
	//fmt.Println(t2)

	date := time.Now()
	date = time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, date.Location())

	date = time.Unix(int64(1512057600), 0)
	date = time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, date.Location())

	monthBeginTime := time.Date(date.Year(), date.Month(), 1, 0, 0, 0, 0, date.Location())
	if date.Day() == 1 {
		// 如果是1号, 则取上个月的流水
		monthBeginTime = monthBeginTime.AddDate(0, -1, 0)
	}
	monthEndTime := date

	fmt.Println(monthBeginTime)
	fmt.Println(monthEndTime)
}
